package com.knowledgegraph.web.controller.zhongyao;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.knowledgegraph.common.annotation.Log;
import com.knowledgegraph.common.core.controller.BaseController;
import com.knowledgegraph.common.core.domain.AjaxResult;
import com.knowledgegraph.common.enums.BusinessType;
import com.knowledgegraph.zhongyao.domain.Prescriptiontype;
import com.knowledgegraph.zhongyao.service.IPrescriptiontypeService;
import com.knowledgegraph.common.utils.poi.ExcelUtil;
import com.knowledgegraph.common.core.page.TableDataInfo;

/**
 * prescriptiontypeController
 * 
 * @author ruoyi
 * @date 2023-07-03
 */
@RestController
@RequestMapping("/zhongyao/prescriptiontype")
public class PrescriptiontypeController extends BaseController
{
    @Autowired
    private IPrescriptiontypeService prescriptiontypeService;

    /**
     * 查询prescriptiontype列表
     */
    @PreAuthorize("@ss.hasPermi('zhongyao:prescriptiontype:list')")
    @GetMapping("/list")
    public TableDataInfo list(Prescriptiontype prescriptiontype)
    {
        startPage();
        List<Prescriptiontype> list = prescriptiontypeService.selectPrescriptiontypeList(prescriptiontype);
        return getDataTable(list);
    }

    /**
     * 导出prescriptiontype列表
     */
    @PreAuthorize("@ss.hasPermi('zhongyao:prescriptiontype:export')")
    @Log(title = "prescriptiontype", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Prescriptiontype prescriptiontype)
    {
        List<Prescriptiontype> list = prescriptiontypeService.selectPrescriptiontypeList(prescriptiontype);
        ExcelUtil<Prescriptiontype> util = new ExcelUtil<Prescriptiontype>(Prescriptiontype.class);
        util.exportExcel(response, list, "prescriptiontype数据");
    }

    /**
     * 获取prescriptiontype详细信息
     */
    @PreAuthorize("@ss.hasPermi('zhongyao:prescriptiontype:query')")
    @GetMapping(value = "/{prescriptionkey}")
    public AjaxResult getInfo(@PathVariable("prescriptionkey") String prescriptionkey)
    {
        return AjaxResult.success(prescriptiontypeService.selectPrescriptiontypeByPrescriptionkey(prescriptionkey));
    }

    /**
     * 新增prescriptiontype
     */
    @PreAuthorize("@ss.hasPermi('zhongyao:prescriptiontype:add')")
    @Log(title = "prescriptiontype", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Prescriptiontype prescriptiontype)
    {
        return toAjax(prescriptiontypeService.insertPrescriptiontype(prescriptiontype));
    }

    /**
     * 修改prescriptiontype
     */
    @PreAuthorize("@ss.hasPermi('zhongyao:prescriptiontype:edit')")
    @Log(title = "prescriptiontype", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Prescriptiontype prescriptiontype)
    {
        return toAjax(prescriptiontypeService.updatePrescriptiontype(prescriptiontype));
    }

    /**
     * 删除prescriptiontype
     */
    @PreAuthorize("@ss.hasPermi('zhongyao:prescriptiontype:remove')")
    @Log(title = "prescriptiontype", businessType = BusinessType.DELETE)
	@DeleteMapping("/{prescriptionkeys}")
    public AjaxResult remove(@PathVariable String[] prescriptionkeys)
    {
        return toAjax(prescriptiontypeService.deletePrescriptiontypeByPrescriptionkeys(prescriptionkeys));
    }
}
